// pages/eventinfo/eventinfo.js
let app=getApp();
Page({
      //页面的初始数据
    data: {
        eventid:null,
        eventtitle:null,
        eventtime:null,
        eventarticle:null,
        imglist:[],
        touxiang:"",
        username:""
    },
    //放大事件图片
    PreviewImage(e)
    {
        let i=e.currentTarget.dataset.id;
        wx.previewImage({
            current:this.data.imglist[i],
            urls:this.data.imglist,
          })
    },
     //生命周期函数--监听页面加载
    onLoad: function (options) {
        this.data.eventid=options.id;
        this.getevent();
    },
    onShow:function(){
     this.setData({
         touxiang:app.globalData.touxiang,
         username:app.globalData.username
     })
    },

   
    //根据eventid获取事件详情
    getevent()
    {
        let that=this;
        wx.request({
            url:app.globalData.url+'/getEvent', 
            header: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' },
            data: {
                eventid:that.data.eventid
             },
             method: 'post',
             success: function (res) {
                  console.log("成功",res.data);
                  that.setData({
                      eventarticle:res.data.eventarticle,
                      eventtime:res.data.eventtime,
                      eventtitle:res.data.eventtitle
                  })
             },
             fail:function(err){//请求失败之后要做什么
                console.log('请求失败')
                }     
        })
        wx.request({
            url:app.globalData.url+'/geteventpic', 
            header: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' },
            data: {
                eventid:that.data.eventid
             },
             method: 'post',
             success: function (res) {
                  that.setData({
                      imglist:res.data
                  })
             },
             fail:function(err){//请求失败之后要做什么
                console.log('请求失败')
                }  
        })
    },
})